package leetcode.median;

import java.util.Arrays;

/**
 * ClassName: $45_jump
 * Description:
 * date: 2021-11-13 10:08
 *
 * @author liyifan
 */
public class $45_jump {
    public int jump(int[] nums) {
        int[] dp = new int[nums.length];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        for (int i = 0;i < nums.length;i++) {
            for (int j = 0;j < i;j++) {
                if (nums[j] + j >= i)
                    dp[i] = Math.min(dp[i], dp[j] + 1);
            }
        }
        return dp[nums.length - 1];
    }
}
